package cn.ronghuanet.auth.controller;

import cn.ronghuanet.auth.annotation.RonghuanetPermission;
import cn.ronghuanet.auth.domain.Menu;
import cn.ronghuanet.auth.service.IMenuService;
import cn.ronghuanet.base.util.AjaxResult;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

@RestController
@RequestMapping("/menu")
@RonghuanetPermission(name="菜单查询",desc = "管理菜单的")
public class MenuController {
    @Autowired
    private IMenuService menuService;

    @GetMapping("/{id}")
    @RonghuanetPermission(name = "查询菜单",desc = "根据用户的id 查询对应的一级菜单和二级菜单 ")
    public AjaxResult getMenuById(@PathVariable("id") Long id){
        try {
           List<Menu> list = menuService.getMenuById(id);
           return AjaxResult.success(list);
        } catch (Exception e) {
            e.printStackTrace();
        }
        return new AjaxResult().error();
    }

}
